const express = require('express')
const app = express()

// 中间件
const middleware = (req, res, next) => {
  console.log('middleware 处理中……')
  next()
}

// 注册全局中间件
app.use(middleware)

// http://127.0.0.1/api/get
app.get('/api/get', (req, res) => {
  res.send('Hello world!')
})

// http://127.0.0.1/api/post
app.post('/api/post', (req, res) => {
  res.send('Hello world!')
})

app.listen(80, () => {
  console.log('Server running at http://127.0.0.1')
})
